package com.guanzi.big_data_mq_process.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.guanzi.big_data_mq_process.model.enums.LocalTransactionStateEnum;
import com.guanzi.big_data_mq_process.model.enums.MessageStatusEnum;
import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 本地消息表
 *
 * @author xuguang
 * @since 2025-05-07 14:41:50
 */
@Data
@TableName("transaction_message")
public class TransactionMessage implements Serializable {

    /**
     * 消息唯一标识
     */
    @TableId(value = "message_id", type = IdType.AUTO)
    private String messageId;


    /**
     * 业务ID（订单号）
     */
    private String bizId;


    /**
     * MQ主题
     */
    private String topic;


    /**
     * MQ标签
     */
    private String tag;


    /**
     * 消息内容
     */
    private String payload;


    /**
     * 0-待发送 1-已发送 2-已完成
     */
    private MessageStatusEnum status;


    /**
     * 事务状态 PREPARED/COMMITTED/ROLLBACKED
     */
    private LocalTransactionStateEnum txState;


    /**
     * 重试次数
     */
    private Integer retryCount;


    /**
     * 下次重试时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp nextRetryTime;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createdTime;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updatedTime;


}
